﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.Linq;

using ProjectBase.Core;

namespace ProjectBase.Mvc
{
    /// <summary>html &lt;SELECT&gt; element</summary>
    public class Select : ContentControl<ICoreModel, ISelectChild, Select>
    {
        #region constructor
        public Select(string cssClassName = null)
            : base(cssClassName) { }
        #endregion constructor

        #region Set
        public virtual Select SetMultiple(bool isMultiple)
        {
            if (isMultiple)
            {
                Multiple = Attr.Multiple;
            }
            else
            {
                Attributes.Remove(Attr.Multiple);
            }
            return this;
        }

        public virtual Select SetName(string name)
        {
            Name = name;
            return this;
        }

        public virtual Select SetSize(int? size)
        {
            if (size.HasValue)
            {
                Size = size.Value.ToString(CultureInfo.InvariantCulture);
            }
            return this;
        }

        public virtual Select SetDisabled(bool isDisabled)
        {
            if (isDisabled)
            {
                Disabled = Attr.Disabled;
            }
            else
            {
                Attributes.Remove(Attr.Disabled);
            }
            return this;
        }

        public virtual Select SetSelected(bool isSelected)
        {
            if (isSelected)
            {
                Selected = Attr.Selected;
            }
            else
            {
                Attributes.Remove(Attr.Selected);
            }
            return this;
        }
        #endregion Set

        #region properties
        protected override string TagName
        {
            get { return Tag.Select; }
        }

        public virtual string Selected
        {
            get { return GetAttribute(Attr.Selected); }
            set { SetAttribute(Attr.Selected, value); }
        }

        public virtual string Disabled
        {
            get { return GetAttribute(Attr.Disabled); }
            set { SetAttribute(Attr.Disabled, value); }
        }

        public virtual string Size
        {
            get { return GetAttribute(Attr.Size); }
            set { SetAttribute(Attr.Size, value); }
        }

        public virtual string Name
        {
            get { return GetAttribute(Attr.Name); }
            set { SetAttribute(Attr.Name, value); }
        }

        public virtual string Multiple
        {
            get { return GetAttribute(Attr.Multiple); }
            set { SetAttribute(Attr.Multiple, value); }
        }
        #endregion properties
    }
}